from sqlalchemy import TEXT, ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column, relationship

from .base import TimedBaseModel


class CheckMessage(TimedBaseModel):
    __tablename__ = "check_message"
    __mapper_args__ = {"eager_defaults": True}

    id: Mapped[int] = mapped_column(primary_key=True)
    text_ru: Mapped[str] = mapped_column(TEXT)
    text_en: Mapped[str] = mapped_column(TEXT)
    text_uk: Mapped[str] = mapped_column(TEXT)
    media_filename: Mapped[str | None] = mapped_column(String(255))
    calendars = relationship(
        "Calendar",
        secondary="calendars_check_messages",
        back_populates="check_messages",
    )

    def __repr__(self):
        return f"<Проверочное сообщение №{self.id}>"

    def __str__(self):
        return self.__repr__()
